package com.genericity;

import java.util.function.IntConsumer;

public class Pair<T, U> {
    private T first;
    private T second;

    public Pair() {
        this.first = null;
        this.second =null;
    }

    public Pair(T first, T second) {
        this.first = first;
        this.second = second;
    }

    public T getFirst() {
        return this.first;
    }

    public T getSecond() {
        return this.second;
    }

    public void setFirst(T first) {
        this.first = first;
    }

    public void setSecond(T second) {
        this.second = second;
    }

    public static <T extends Comparable & IntConsumer> T getMin(T[] a) { // 限定泛型T必须是实现了Comparable和IntConsumer接口的类型
        if(a[0].compareTo(a[1]) != 0) {
            return a[0];
        }
        return a[1];
    }
}
